import request from "@/utils/request";
import axios from "axios";
import qs from "qs";
import config from "../../config";

// let service;
// if (process.env.NODE_ENV === "development") {
//   service = axios.create();
// } else {
//   // 基本实例
//   service = axios.create({
//     baseURL: `${process.env.VUE_APP_API_URL_PREFIX}`,
//   });
// }

/**
 * */
export function getSiteMenu() {
  return request({
    url: `${config.cciauth.path}/sessionBased/siteList`,
    method: "get",
  });
}

export function login(data) {
  return axios({
    url: `${config.cciauth.path}/login`,
    method: "post",
    params: {
      json_response: true,
    },
    data: qs.stringify(data),
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
  });
}

export function loginOut(data) {
  return request({
    url: `${config.cciauth.path}/logout`,
    method: "post",
    data,
  });
}

export function changePwd(data) {
  return request({
    url: `${config.cciauth.path}/sessionBased/userService/changePwd`,
    method: "post",
    data,
  });
}

export function loginCheck() {
  return request({
    url: `${config.cciauth.path}/loginCheck`,
    method: "get",
  });
}

export function getParams() {
  return request({
    url: `${config.cciauth.path}/nonSessionBased/getParameterList`,
    method: "get",
  });
}
